package yzy.ecps.service;

import java.util.List;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import yzy.ecps.model.Cart;
import yzy.ecps.model.ShopCart;

public interface CartService {
	
	/**
	 * 添加商品sku到购物车
	 * @param request
	 * @param response
	 * @param skuId
	 */
	public void addCart(HttpServletRequest request,HttpServletResponse response,Long skuId,Integer quantity)throws Exception;
	
	/**
	 * 检测用户cookie是否可用
	 * @param request
	 * @param response
	 * @return 禁用返回"no",可用返回"yes"
	 */
	public String validCookie(HttpServletRequest request,HttpServletResponse response);
	
	/**
	 * 修改指定商品sku在购物车中的数量
	 * @param request
	 * @param response
	 * @param skuId
	 * @param quantity
	 */
	public void updateCart(HttpServletRequest request,HttpServletResponse response,Long skuId,Integer quantity) throws Exception;
	
	
	/**
	 * 获取购物车的Cookie 不存在返回null
	 * @param request
	 * @param response
	 * @return
	 */
	public Cookie getCartCookie(HttpServletRequest request) throws Exception;
	
	/**
	 * 检测购物车中是否可以添加指定数量商品 可以返回yes,不能返回no
	 * @param cartCookie
	 * @param skuId
	 * @param quantity
	 * @return
	 * @throws Exception
	 */
	public String validStock(HttpServletRequest request,Long skuId,Integer quantity)throws Exception;
	
	/**
	 * 获取购物车中所有商品sku的信息
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public List<ShopCart> getCartInfo(HttpServletRequest request) throws Exception;
	
	/**
	 * 获取购物车中所有商品的信息,并将sku信息按商品分类
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public List<Cart> getCartGroupByGoods(HttpServletRequest request) throws Exception;
	
	/**
	 * 删除一个购物车项
	 * @param request
	 * @param response
	 * @param skuId
	 * @throws Exception
	 */
	public void deleteCart(HttpServletRequest request,HttpServletResponse response,Long skuId)throws Exception;
	
	/**
	 * 清空购物车
	 * @param request
	 * @param response
	 * @throws Exception
	 */
	public void clearCart(HttpServletRequest request,HttpServletResponse response)throws Exception;
}
